home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / UUCP / UUCon / Source / Subprocess.h < prev    next >
Text File  |  1993-01-31  |  3KB  |  96 lines

  1. /*----------------------------------------------------------------------------
  2.     Subprocess.h
  3.     
  4.     From Subprocess example by Charles L. Oei
  5.                                     pty support by Joe Freeman
  6.                                     with encouragement from Kristofer Younger
  7.                                     Subprocess Example, Release 2.0
  8.                                     NeXT Computer, Inc.
  9.     
  10.     You may freely copy, distribute and reuse the code in this example.
  11.     NeXT disclaims any warranty of any kind, expressed or implied, as to
  12.     its fitness for any particular use.
  13.  
  14.   This subprocess object sends/receives data to/from any UNIX
  15.   subprocess asynchronously (via vfork/pipe).
  16.   Its delegate, if any, will receive the following messages:
  17.  
  18.     - subprocess:sender done:(int)exitStatus;
  19.         sent when the subprocess exits
  20.   
  21.     - subprocess:sender output:(char *)buffer;
  22.         sent whenever there is data on the standard output pipe;
  23.         buffer is only valid until next call
  24.  
  25.     - subprocess:sender stderrOutput:(char *)buffer;
  26.         sent whenever there is data on the standard error pipe;
  27.         buffer is only valid until next call.
  28.  
  29.     - subprocess:sender error:(const char *)errorString;
  30.         sent when an error occurs;
  31.         if it ever happens, it's usually only at startup time
  32.  
  33.     REVISIONS
  34.     Subprocess.h,v
  35.  * Revision 1.3  1993/02/01  02:21:29  nwc
  36.  * Added baud rate button. Cleaned interface. Fixed subprocess bug.
  37.  *
  38.  * Revision 1.2  1992/09/03  16:33:45  nwc
  39.  * Clean up after Subprocesses.
  40.  *
  41.  * Revision 1.1.1.1  1992/08/18  14:34:20  nwc
  42.  * GENESIS
  43.  *
  44.  * Revision 1.1  1992/07/04  03:17:22  nwc
  45.  * Initial revision
  46.  *
  47. ----------------------------------------------------------------------------*/
  48. #import <stdio.h>
  49. #import <objc/Object.h>
  50.  
  51. #define SUBPROCESS_STOPPED        -1
  52. #define SUBPROCESS_SIGNALED        -2
  53.  
  54. @interface Subprocess:Object
  55. {    
  56.    FILE        *fpToChild;
  57.    FILE        *fpFromChild;
  58.    int        fromChild;
  59.    int        stderrFromChild;
  60.    int        childPid;
  61.    id        delegate;
  62.    char        outputBuffer[BUFSIZ];
  63.    int        outputBufferLen;
  64.    int        stderrBufferLen;
  65.    char        stderrBuffer[BUFSIZ];
  66.    BOOL        paused;
  67.    BOOL        running;
  68.    BOOL        markedForFree;             /* free's are delayed */
  69. }
  70.  
  71. - init:(const char *)subprocessString;
  72. - init:(const char *)subprocessString withDelegate:theDelegate;
  73.  
  74. - setDelegate:anObject;
  75. - delegate;
  76. - send:(const char *)string withNewline:(BOOL)wantNewline;
  77. - send:(const char *)string;
  78. - (int)pid;
  79. - (BOOL)isPaused;
  80. - pause:sender;
  81. - resume:sender;
  82. - (BOOL)isRunning;
  83. - terminate:sender;
  84. - terminateInput;
  85.  
  86. @end
  87.  
  88. @interface Object(SubprocessDelegate)
  89.  
  90. - subprocess:sender done:(int)exitStatus;
  91. - subprocess:sender output:(char *)buffer;
  92. - subprocess:sender stderrOutput:(char *)buffer;
  93. - subprocess:sender error:(const char *)errorString;
  94.  
  95. @end
  96.